/*
 * @Author: username 1718324422@qq.com
 * @Date: 2022-10-24 15:31:25
 * @LastEditors: zhuxin xu
 * @LastEditTime: 2023-01-29 14:42:40
 * @FilePath: \xu_vue\src\api\axios.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from "axios";
const requests = axios.create({
  baseURL: "/",
  timeout: 2 * 1000 * 60
});
//请求拦截器
requests.interceptors.request.use(
  config => {
    console.log(config);
    //在请求拦截器给请求头加token
    const token = localStorage.getItem("token");
    token && (config.headers.token = token);
  },
  error => {
    console.log(error);
  }
);
//响应拦截器
requests.interceptors.response.use(ins => {
  console.log(ins);
});

export default requests;
